package com.example.smartmedicalsystem.repository;

import com.example.smartmedicalsystem.entity.Appointment;
import com.example.smartmedicalsystem.entity.Doctor;
import com.example.smartmedicalsystem.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;

public interface AppointmentRepository extends JpaRepository<Appointment, Long> {
    @Query("SELECT a FROM Appointment a LEFT JOIN FETCH a.medicalRecord WHERE a.patient = :patient")
    List<Appointment> findByPatientWithMedicalRecord(@Param("patient") User patient);

    List<Appointment> findByDoctorAndStatus(Doctor doctor, Appointment.Status status);
}